home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
United Public Domain Gold 2
/
United Public Domain Gold 2.iso
/
utilities
/
pu022.dms
/
pu022.adf
/
Source
/
Source.LZH
/
extra.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-12-05
|
5KB
|
227 lines
#include <stdio.h>
#include <intuition/intuitionbase.h>
#include <graphics/gfxbase.h>
#include <exec/types.h>
#define EXIST 0
#define EXECUTE 1
#define WRITE 2
#define READ 4
extern char ProgId[],Version[];
extern int Revision;
extern char UserId[],Date[];
void WrConWin();
Block(win,col,x1,y1,width,height) /* Block zeichnen */
struct Window *win;
int col,x1,y1,width,height;
{
struct RastPort *RP;
if(width==0 || height ==0) return;
RP=win->RPort;
SetDrMd(RP,JAM1);
SetAPen(RP,col);
RectFill(RP,x1,y1,x1+width-1,y1+height-1);
}
Box(win,col1,col2,x1,y1,width,height) /* leere Box mit Rahmen zeichnen */
struct Window *win;
int col1,col2,x1,y1,width,height;
{
struct RastPort *RP;
if(width==0 || height==0) return;
RP=win->RPort;
SetDrMd(RP,JAM1);
SetAPen(RP,col1);
RectFill(RP,x1,y1,x1+width-1,y1+height-1);
SetAPen(RP,col2);
RectFill(RP,x1+1,y1+1,x1+width-2,y1+height-2);
}
Check_Pathname(Pfadname)
char *Pfadname;
{
int l;
l=strlen(Pfadname);
if (l)
{
if(Pfadname[l-1]!=':' && Pfadname[l-1]!='/')
strcat(Pfadname,"/");
}
}
Cls(win,col) /* Bildschirm löschen in Farbe col */
struct Window *win;
int col;
{
Move(win->RPort,0,0); /* Rastport in die obere linke Ecke setzen */
SetRast(win->RPort,col);
RefreshWindowFrame(win);
RemakeDisplay();
}
Ellipse(win,col,x,y,rx,ry) /* Ellipse zeichnen */
struct Window *win;
int col,x,y,rx,ry;
{
struct RastPort *RP;
RP=win->RPort;
SetDrMd(RP,JAM1);
SetAPen(RP,col);
DrawEllipse(RP,x,y,rx,ry);
}
/* oeffnet CONSOLE-Window f. (Revision-)Messages */
int OpenRevWin(size)
char *size;
{
int window;
char Str1[180],Str2[190];
window=open(size,2,0);
if(window==-1)
return(-1);
sprintf(Str1,"%s %s - Revision %d\n\n",ProgId,Version,Revision);
sprintf(Str2,"latest update by: %s %s\n\n",UserId,Date);
WrConWin(window,Str1);
WrConWin(window,Str2);
return(window);
}
Pixel(win,col,x,y) /* Punkt setzen */
struct Window *win;
int col,x,y;
{
struct RastPort *RP;
RP=win->RPort;
SetDrMd(RP,JAM1);
SetAPen(RP,col);
WritePixel(RP,x,y);
}
Print(win,text,col1,col2,xpos,ypos) /* Ausgabe von Text */
struct Window *win;
char *text;
int col1,col2,xpos,ypos;
{
int dx=4,width=win->GZZWidth;
struct RastPort *RP;
/* if((width-strlen(text)*8) < 0) return; */ /* Text zu lang */
RP=win->RPort;
SetDrMd(RP,JAM2);
SetAPen(RP,col1);
SetBPen(RP,col2);
if (win->Flags & GIMMEZEROZERO) dx=0;
if(xpos == -1) xpos=(width-strlen(text)*8)/2+dx; /* zentriert */
if(xpos == -2) xpos=width-strlen(text)*8+dx; /* rechtsbündig */
Move(RP,xpos,ypos);
Text(RP,text,strlen(text));
}
ReqBlock(req, col, x1, y1, width, height)
struct Requester *req;
int col, x1, y1, width, height;
{
struct RastPort *RP;
if (width == 0 || height == 0)
return;
RP = req->ReqLayer->rp;
SetDrMd(RP, JAM1);
SetAPen(RP, col);
RectFill(RP, x1, y1, x1 + width - 1, y1 + height - 1);
}
ReqBox(req,col1,col2,x1,y1,width,height) /* leere Box mit Rahmen im
Requester zeichnen */
struct Requester *req;
int col1,col2,x1,y1,width,height;
{
struct RastPort *RP;
if(width==0 || height==0) return;
RP=req->ReqLayer->rp;
SetDrMd(RP,JAM1);
SetAPen(RP,col1);
RectFill(RP,x1,y1,x1+width-1,y1+height-1);
SetAPen(RP,col2);
RectFill(RP,x1+1,y1+1,x1+width-2,y1+height-2);
}
ReqPrint(req,text,col1,col2,xpos,ypos) /* Ausgabe von Text */
struct Requester *req;
char *text;
int col1,col2,xpos,ypos;
{
int width=req->Width;
struct RastPort *RP;
RP=req->ReqLayer->rp;
SetDrMd(RP,JAM2);
SetAPen(RP,col1);
SetBPen(RP,col2);
if(xpos == -1) xpos=(width-strlen(text)*8)/2; /* zentriert */
if(xpos == -2) xpos=width-strlen(text)*8; /* rechtsbündig */
Move(RP,xpos,ypos);
Text(RP,text,strlen(text));
}
Shadow(win,text,txtc,shdwc,xpos,ypos) /* Ausgabe von Text */
struct Window *win; /* mit Schatten */
char *text;
int txtc,shdwc,xpos,ypos;
{
int dx=4,width=win->GZZWidth;
struct RastPort *RP;
RP=win->RPort;
SetDrMd(RP,JAM1);
SetAPen(RP,shdwc);
if(win->Flags & GIMMEZEROZERO) dx=0;
if(xpos==-1) xpos=(width-strlen(text)*8)/2+dx;
if(xpos==-2) xpos=width-strlen(text)*8+dx;
Move(RP,xpos+1,ypos+1);
Text(RP,text,strlen(text));
SetAPen(RP,txtc);
Move(RP,xpos,ypos);
Text(RP,text,strlen(text));
}
int strpos(s1,s2)
char *s1,*s2;
{
register int i;
int n,pos=0,flag=0;
if(strlen(s2) > strlen(s1)) return -1;
for(i=0;i<strlen(s1)-strlen(s2)+1;i++)
{
n=strncmp(&s1[i],s2,strlen(s2));
if(n==0)
{
pos=i;
flag=1;
break;
}
}
if(!flag) pos=-1;
return pos;
}
BOOL TestFile(file)
char *file;
{
int Erfolg;
Erfolg=access(file,EXIST);
if(Erfolg==0) return (TRUE);
else return (FALSE);
}
void WrConWin(win,text)
int win;
char *text;
{
write(win,text,strlen(text));
}